package auto;

import java.awt.Color;
import java.awt.Dialog.ModalityType;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class CenterPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2609220410101318653L;

	private JButton dugme1 = null;
	private JButton dugme2 = null;
	private JLabel label1;
	private JTextField tf;

	GridBagLayout gbl = new GridBagLayout();
	GridBagConstraints gbc = new GridBagConstraints();

	public CenterPanel() {
		setLayout(gbl);
		add(getButton1());
		add(getButton2());
		add(getField());
		
	}
	
	private CenterPanel cp = this;
	
	public void setBtn1Back(Color boja){
		dugme1.setBackground(boja);
	}
	
	public JButton getButton1() {
		if (dugme1 == null) {
			dugme1 = new JButton();
			dugme1.setPreferredSize(new Dimension(153, 256));
			dugme1.setBackground(Color.GREEN);
			gbc.gridx = 1;
			gbc.gridy = 1;
			gbl.setConstraints(dugme1, gbc);
			dugme1.addActionListener(new ActionListener() {

				@Override
				public void actionPerformed(ActionEvent e) {
					if (dugme1.getBackground() == Color.GREEN) {
						AktivacijaPranje ap = new AktivacijaPranje(1, cp);
						ap.setVisible(true);
						ap.setAlwaysOnTop(true);
					} else {
						dugme1.setBackground(Color.GREEN);
					}
				}
			});

		}
		return dugme1;

	}

	private JLabel getField() {
		Dimension dim = new Dimension(300, 20);
		label1 = new JLabel();
		label1.setPreferredSize(dim);
		gbc.gridx = 3;
		gbc.gridy = 1;
		gbl.setConstraints(label1, gbc);

		return label1;

	}

	private JButton getButton2() {
		if (dugme2 == null) {
			dugme2 = new JButton();
			dugme2.setPreferredSize(new Dimension(153, 256));
			dugme2.setBackground(Color.GREEN);
			gbc.gridx = 4;
			gbc.gridy = 1;
			gbl.setConstraints(dugme2, gbc);
			dugme2.addActionListener(new ActionListener() {

				@Override
				public void actionPerformed(ActionEvent e) {

					if (dugme2.getBackground() == Color.GREEN) {
						AktivacijaPranje ap = new AktivacijaPranje();
						ap.setVisible(true);
						ap.setAlwaysOnTop(true);

					} else {
						dugme2.setBackground(Color.GREEN);
					}
				}
			});

		}
		return dugme2;

	}

	public void gbcXY(int x, int y) {
		gbc.gridx = x;
		gbc.gridy = y;
		gbc.insets = new Insets(10, 10, 10, 10);
	}

}
